<script setup lang="ts">
import { onMounted, onUnmounted } from 'vue'
import { eventBus } from '@/utils/eventBus'

onMounted(() => {
  // 监听事件
  const handleMessage = (msg: string) => {
    console.log(`Received message: ${msg}`)
  }
  eventBus.on('messageSent', handleMessage)

  // 清理，避免内存泄漏
  onUnmounted(() => {
    eventBus.off('messageSent', handleMessage)
  })
})
</script>
